<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
	    <meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" />
        <title>Using Require.js - httpx.js Examples</title>
        <link rel="stylesheet" href="css/global.css">
    </head>
    <body>
        <div id="layout">
            <header>
                <h1>Using Require.js Example</h1>    
                <a href="index.html" class="btn">Back to index</a>               
            </header>
            <pre id="output">Loading ...</pre>
            <pre id="output2">Loading ...</pre>
        </div>
        <script src="./js/require.min.js"></script>
        <script>   
            var $ = function(id) {
                return document.getElementById(id);
            };
            
            require(["../src/httpx.js"], function(httpx) {
                console.log(httpx);

                httpx.get("http://localhost/http-test/get.php", {
                    a : 12,
                    b : "bbbb",
                    c : 123489
                }, function(data) {
                    console.log(data, this);
                }, function(method, url) {
                    console.error("Custom Error", method, url);
                });

                httpx.get("http://localhost/http-test/get.php", {
                    a : 12,
                    b : "bbbb",
                    c : 123489
                }, function(data) {
                    console.log(data, this);
                });
                
                httpx.getJSON("http://localhost/http-test/get-json.php?temp="+(new Date).getTime(), {test:123}, function(json) {
                    console.log("getJSON =>", json);                
                });
            
                httpx.jsonp("http://localhost/httpx.js/examples/php/jsonp.php?temp=" + (new Date).getTime(), {test : 123, id : 4556656, title : "Title 中文标题"}, function(json, url) {
                    console.log("jsonp =>", json);  
                    $("output").innerText = url + "\n\n" + JSON.stringify(json);            
                });

                httpx.jsonp("http://192.168.1.2/httpx.js/examples/php/jsonp.php?temp=" + (new Date).getTime(), {test : 123, id : 4556656, title : "Title 中文标题"}, function(json, url) {
                    console.log("jsonp2 =>", json);  
                    $("output2").innerText = url + "\n\n" + JSON.stringify(json);            
                });
            });
        </script>
    </body>
</html>